temp <- unlist(gregexpr(pattern ='\\|',as.character(qual_data$FL_8_DO)))
qual_data$M1_name <- substr(qual_data$FL_8_DO,1,temp-1)
qual_data$M2_name <- substr(qual_data$FL_8_DO,temp+1,nchar(as.character(qual_data$FL_8_DO)))
default_music_order <- paste0('M',1:4,'-',c('Stalker','Hutch','Trees','Piggy'))
M_order <- matrix(NA,length(qual_data$M1_name),2)
# Recoding the randomization of the videos
temp <- unlist(gregexpr(pattern ='\\|',as.character(qual_data$FL_13_DO)))
qual_data$V1_name <- substr(qual_data$FL_13_DO,1,temp-1)
qual_data$V2_name <- substr(qual_data$FL_13_DO,temp+1,nchar(as.character(qual_data$FL_13_DO)))
default_video_order <- paste0('V',1:3,'-',c('Face','Hear','Hills'))
V_order <- matrix(NA,length(qual_data$V1_name),2)
# Numeric form of the actual order
for (i in 1:nrow(V_order)){
V_order[i,1] <- which(default_video_order %in% qual_data$V1_name[i])
V_order[i,2] <- which(default_video_order %in% qual_data$V2_name[i])
M_order[i,1] <- which(default_music_order %in% qual_data$M1_name[i])
M_order[i,2] <- which(default_music_order %in% qual_data$M2_name[i])
}
# Using Numeric form to obtain emotion rating for Fear only and get compar vector with 1 and 0
M_order_data <- matrix(NA,length(qual_data$M1_name),2)
V_order_data <- matrix(NA,length(qual_data$M1_name),2)
M_compare_data <- matrix(NA,length(qual_data$M1_name),2)
V_compare_data <- matrix(NA,length(qual_data$M1_name),2)
for (i in 1:nrow(V_order)){
eval(parse(text=paste0('m<-c(qual_data$M',M_order[i,1],'.Emotions_3[',i,'],',
'qual_data$M',M_order[i,2],'.Emotions_3[',i,'])')))
M_order_data[i,] <- m
if (qual_data$M.Compare[i] == 'The First Option'){
M_compare_data[i,] <- c(1,0)
}else{
M_compare_data[i,] <- c(0,1)
}
eval(parse(text=paste0('v<-c(qual_data$V',V_order[i,1],'.Emotions_3[',i,'],',
'qual_data$V',V_order[i,2],'.Emotions_3[',i,'])')))
V_order_data[i,] <- v
if (qual_data$V.Compare[i] == 'The First Option'){
V_compare_data[i,] <- c(1,0)
}else{
V_compare_data[i,] <- c(0,1)
}
}
# Music
## Residuals
fit_1m <- lm(M_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2m <- lm(M_order_data[,2] ~ qual_data$Pre.Emotions_3)
M_residuals <- cbind(residuals(fit_1m),residuals(fit_1m))
# Change
M_change <- M_order_data - qual_data$Pre.Emotions_3
# Video
## Residuals
fit_1v <- lm(V_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2v <- lm(V_order_data[,2] ~ qual_data$Pre.Emotions_3)
V_residuals <- cbind(residuals(fit_1v),residuals(fit_1v))
# Change
V_change <- V_order_data - qual_data$Pre.Emotions_3
long_format <- data.frame(ID=rep(1:50,4),
Rating=c(M_order_data,V_order_data),
R_change=c(M_change,V_change),
Votes=c(M_compare_data,V_compare_data),
Type=rep(c('Music','Video'),each=length(M_order)),
Type_Order=rep(c(rep(1,nrow(M_order)),rep(2,nrow(M_order))),2),
Overall_Order=rep(1:4,each=nrow(M_order)),
Name=c(substr(default_music_order[M_order],4,8),
substr(default_video_order[V_order],4,7))
)
# Change
M_change <- M_order_data - qual_data$Pre.Emotions_3
class(M_order_data)
class(qual_data$Pre.Emotions_3)
M_change <- M_order_data - as.numeric(qual_data$Pre.Emotions_3)
View(M_order_data)
M_change <- M_order_data[,1] - as.numeric(qual_data$Pre.Emotions_3)
M_change <- as.numeric(M_order_data[,1]) - as.numeric(qual_data$Pre.Emotions_3)
# Video
## Residuals
fit_1v <- lm(V_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2v <- lm(V_order_data[,2] ~ qual_data$Pre.Emotions_3)
V_residuals <- cbind(residuals(fit_1v),residuals(fit_1v))
V_change <- as.numeric(V_order_data[,1]) - as.nunmeric(qual_data$Pre.Emotions_3)
V_change <- as.numeric(V_order_data[,1]) - as.numeric(qual_data$Pre.Emotions_3)
long_format <- data.frame(ID=rep(1:50,4),
Rating=c(M_order_data,V_order_data),
R_change=c(M_change,V_change),
Votes=c(M_compare_data,V_compare_data),
Type=rep(c('Music','Video'),each=length(M_order)),
Type_Order=rep(c(rep(1,nrow(M_order)),rep(2,nrow(M_order))),2),
Overall_Order=rep(1:4,each=nrow(M_order)),
Name=c(substr(default_music_order[M_order],4,8),
substr(default_video_order[V_order],4,7))
)
music <- subset(long_format,long_format$Type=='Music'); music$Name <- factor(music$Name)
video <- subset(long_format,long_format$Type=='Video'); video$Name <- factor(video$Name)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
v_descriptives <- describeBy(video$Rating,group = video$Name, mat = TRUE)
install.packages("psych")
require(psych)
remove.packages("mnormt")
install.packages("mnormt")
install.packages("mnormt")
install.packages("psych")
require(psych)
install.packages("psych")
install.packages("tmvnsim")
install.packages("psych")
require(psych)
require(psych)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
v_descriptives <- describeBy(video$Rating,group = video$Name, mat = TRUE)
music <- subset(long_format,long_format$Type=='Music'); music$Name <- factor(music$Name)
video <- subset(long_format,long_format$Type=='Video'); video$Name <- factor(video$Name)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
m_descriptives <- describeBy(as.numeric(music$Rating),group = music$Name, mat = TRUE)
v_descriptives <- describeBy(as.numeric(video$Rating),group = video$Name, mat = TRUE)
kable(table(music$Name), col.names = c('Name', 'Frequency'), caption = 'Music Frequency Table')
kable(table(video$Name), col.names = c('Name', 'Frequency'), caption = 'Video Frequency Table')
limits <- aes(ymax = mean + (1.645*se), ymin=mean - (1.645*se)) # 90% Confidence intervals
dodge <- position_dodge(width=0.9)
j_dodge <- position_jitterdodge(dodge.width=.9, jitter.width = 1.5)
# Bar Graph
# Help from: http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/
p <- ggbarplot(music, x='Name', y='R_change', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = music, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Name), y = R_change, fill=Name, color=Name)) +
stat_compare_means(method = 'anova', label.y=105) +
ylab('Emotion Rating') +
xlab('Music') +
labs(fill = "Music") +
theme(legend.key = element_rect(colour = NA))
p
# Direct Comparison as opposed to the rating value
p <- ggbarplot(music, x='Name', y='Votes', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
# geom_jitter(data = music, position=j_dodge,show.legend=FALSE,
#        aes(x = as.numeric(Name), y = Votes, fill=Name, color=Name)) +
stat_compare_means(label.y=1.01) +
ylab('Votes') +
xlab('Music') +
labs(fill = "Music") +
theme(legend.key = element_rect(colour = NA))
p
## Videos
p <- ggbarplot(video, x='Name', y='Rating', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = video, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Name), y = Rating, fill=Name, color=Name)) +
stat_compare_means(method = 'anova', label.y=105) +
ylab('Emotion Rating') +
xlab('Video') +
labs(fill = "Video") +
theme(legend.key = element_rect(colour = NA))
View(video)
# Change
M_change <- M_order_data - qual_data$Pre.Emotions_3
# Bar Graph
# Help from: http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/
p <- ggbarplot(music, x='Name', y='R_change', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = music, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Name), y = R_change, fill=Name, color=Name)) +
stat_compare_means(method = 'anova', label.y=105) +
ylab('Emotion Rating') +
xlab('Music') +
labs(fill = "Music") +
theme(legend.key = element_rect(colour = NA))
time_data <- data.frame(Rating=c(qual_data$Pre.Emotions_3,long_format$Rating),
Time=factor(c(rep(0,nrow(M_order)),long_format$Overall_Order),
labels = c('Pre','M1','M2','V1','V2')))
p <- ggbarplot(time_data, x='Time', y='Rating', fill='Time', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = time_data, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Time), y = Rating, fill=Time, color=Time)) +
stat_compare_means(label.y=105, method = 'anova') +
stat_compare_means(label = "p.signif", method = "t.test", paired=TRUE,
ref.group = "Pre") +
ylab('Rating') +
xlab('Time') +
labs(fill = "Time") +
theme(legend.key = element_rect(colour = NA))
require(reshape2)
require(Hmisc)
require(psych)
require(ggplot2)
require(ggpubr)
require(cowplot)
require(gridExtra)
require(grid)
require(ggExtra)
require(ggsci)
require(latex2exp)
require(RColorBrewer)
require(knitr)
# Creating theme for APA in ggplot
apatheme <- theme(panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.border=element_blank(),
panel.background = element_rect(fill = "transparent"),#
axis.line=element_line(),
text=element_text(family='sans'),#
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5),
legend.key = element_rect(fill = "transparent", colour = "transparent", size = 0.25),
legend.box.background = element_rect(fill = "transparent", linetype="solid"),#
plot.background = element_rect(fill = "transparent",colour = NA))#
data_dir = "../01_Data/qualtrics/pilot/raw"
clean_data_dir = "../01_Data/qualtrics/pilot/clean/"
plots_dir = "../03_Plots/pilot-plots/"
f_name <- list.files(path = data_dir, pattern = "*csv")
x <- read.csv(list.files(path = data_dir, pattern = "*csv", full.names = TRUE))
# Remove info from Qualtrics
x <- x[-c(1,2),]
# Save file
new_fname <- paste0(substring(f_name,1,nchar(f_name)-4),'_CLEAN',
substring(f_name,nchar(f_name)-3,nchar(f_name)))
write.csv(x, paste0(clean_data_dir, new_fname), row.names = FALSE)
require(reshape2)
require(Hmisc)
require(psych)
require(ggplot2)
require(ggpubr)
require(cowplot)
require(gridExtra)
require(grid)
require(ggExtra)
require(ggsci)
require(latex2exp)
require(RColorBrewer)
require(knitr)
knitr::opts_chunk$set(echo = FALSE, fig.align="center")
knitr::opts_chunk$set(cache=FALSE)
# knitr::opts_chunk$set(out.width = 1)
options(width = 110)
# Creating theme for APA in ggplot
apatheme <- theme(panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.border=element_blank(),
panel.background = element_rect(fill = "transparent"),#
axis.line=element_line(),
text=element_text(family='sans'),#
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5),
legend.key = element_rect(fill = "transparent", colour = "transparent", size = 0.25),
legend.box.background = element_rect(fill = "transparent", linetype="solid"),#
plot.background = element_rect(fill = "transparent",colour = NA))#
```{r qualtrics_read}
data_dir = "../01_Data/qualtrics/pilot/raw"
clean_data_dir = "../01_Data/qualtrics/pilot/clean/"
plots_dir = "../03_Plots/pilot-plots/"
f_name <- list.files(path = data_dir, pattern = "*csv")
x <- read.csv(list.files(path = data_dir, pattern = "*csv", full.names = TRUE))
# Remove info from Qualtrics
x <- x[-c(1,2),]
# Save file
new_fname <- paste0(substring(f_name,1,nchar(f_name)-4),'_CLEAN',
substring(f_name,nchar(f_name)-3,nchar(f_name)))
write.csv(x, paste0(clean_data_dir, new_fname), row.names = FALSE)
# Read it in again so the numerics are read in now unlike previous time
qual_data <- read.csv(paste0(clean_data_dir, new_fname))
# Remove those that didn't finish and save again
qual_data <- qual_data[qual_data$Progress == 100,]
write.csv(qual_data, paste0(clean_data_dir, new_fname), row.names = FALSE)
# Recoding the randomization of the music
temp <- unlist(gregexpr(pattern ='\\|',as.character(qual_data$FL_8_DO)))
qual_data$M1_name <- substr(qual_data$FL_8_DO,1,temp-1)
qual_data$M2_name <- substr(qual_data$FL_8_DO,temp+1,nchar(as.character(qual_data$FL_8_DO)))
default_music_order <- paste0('M',1:4,'-',c('Stalker','Hutch','Trees','Piggy'))
M_order <- matrix(NA,length(qual_data$M1_name),2)
# Recoding the randomization of the videos
temp <- unlist(gregexpr(pattern ='\\|',as.character(qual_data$FL_13_DO)))
qual_data$V1_name <- substr(qual_data$FL_13_DO,1,temp-1)
qual_data$V2_name <- substr(qual_data$FL_13_DO,temp+1,nchar(as.character(qual_data$FL_13_DO)))
default_video_order <- paste0('V',1:3,'-',c('Face','Hear','Hills'))
V_order <- matrix(NA,length(qual_data$V1_name),2)
# Numeric form of the actual order
for (i in 1:nrow(V_order)){
V_order[i,1] <- which(default_video_order %in% qual_data$V1_name[i])
V_order[i,2] <- which(default_video_order %in% qual_data$V2_name[i])
M_order[i,1] <- which(default_music_order %in% qual_data$M1_name[i])
M_order[i,2] <- which(default_music_order %in% qual_data$M2_name[i])
}
# Using Numeric form to obtain emotion rating for Fear only and get compar vector with 1 and 0
M_order_data <- matrix(NA,length(qual_data$M1_name),2)
V_order_data <- matrix(NA,length(qual_data$M1_name),2)
M_compare_data <- matrix(NA,length(qual_data$M1_name),2)
V_compare_data <- matrix(NA,length(qual_data$M1_name),2)
for (i in 1:nrow(V_order)){
eval(parse(text=paste0('m<-c(qual_data$M',M_order[i,1],'.Emotions_3[',i,'],',
'qual_data$M',M_order[i,2],'.Emotions_3[',i,'])')))
M_order_data[i,] <- m
if (qual_data$M.Compare[i] == 'The First Option'){
M_compare_data[i,] <- c(1,0)
}else{
M_compare_data[i,] <- c(0,1)
}
eval(parse(text=paste0('v<-c(qual_data$V',V_order[i,1],'.Emotions_3[',i,'],',
'qual_data$V',V_order[i,2],'.Emotions_3[',i,'])')))
V_order_data[i,] <- v
if (qual_data$V.Compare[i] == 'The First Option'){
V_compare_data[i,] <- c(1,0)
}else{
V_compare_data[i,] <- c(0,1)
}
}
# Music
## Residuals
fit_1m <- lm(M_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2m <- lm(M_order_data[,2] ~ qual_data$Pre.Emotions_3)
M_residuals <- cbind(residuals(fit_1m),residuals(fit_1m))
# Change
M_change <- M_order_data - qual_data$Pre.Emotions_3
# Video
## Residuals
fit_1v <- lm(V_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2v <- lm(V_order_data[,2] ~ qual_data$Pre.Emotions_3)
V_residuals <- cbind(residuals(fit_1v),residuals(fit_1v))
# Change
V_change <- V_order_data - qual_data$Pre.Emotions_3
long_format <- data.frame(ID=rep(1:50,4),
Type_Order=rep(c(rep(1,nrow(M_order)),rep(2,nrow(M_order))),2),
Overall_Order=rep(1:4,each=nrow(M_order)),
Name=c(substr(default_music_order[M_order],4,8),
substr(default_video_order[V_order],4,7))
)
music <- subset(long_format,long_format$Type=='Music'); music$Name <- factor(music$Name)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
v_descriptives <- describeBy(video$Rating,group = video$Name, mat = TRUE)
music <- subset(long_format,long_format$Type=='Music'); music$Name <- factor(music$Name)
video <- subset(long_format,long_format$Type=='Video'); video$Name <- factor(video$Name)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
require(reshape2)
require(Hmisc)
require(psych)
require(ggplot2)
require(ggpubr)
require(cowplot)
require(gridExtra)
require(grid)
require(ggExtra)
require(ggsci)
require(latex2exp)
require(RColorBrewer)
require(knitr)
knitr::opts_chunk$set(echo = FALSE, fig.align="center")
knitr::opts_chunk$set(cache=FALSE)
# knitr::opts_chunk$set(out.width = 1)
options(width = 110)
# Creating theme for APA in ggplot
apatheme <- theme(panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
panel.border=element_blank(),
panel.background = element_rect(fill = "transparent"),#
axis.line=element_line(),
text=element_text(family='sans'),#
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5),
legend.key = element_rect(fill = "transparent", colour = "transparent", size = 0.25),
legend.box.background = element_rect(fill = "transparent", linetype="solid"),#
plot.background = element_rect(fill = "transparent",colour = NA))#
data_dir = "../01_Data/qualtrics/pilot/raw"
clean_data_dir = "../01_Data/qualtrics/pilot/clean/"
plots_dir = "../03_Plots/pilot-plots/"
f_name <- list.files(path = data_dir, pattern = "*csv")
x <- read.csv(list.files(path = data_dir, pattern = "*csv", full.names = TRUE))
# Remove info from Qualtrics
x <- x[-c(1,2),]
# Save file
new_fname <- paste0(substring(f_name,1,nchar(f_name)-4),'_CLEAN',
substring(f_name,nchar(f_name)-3,nchar(f_name)))
write.csv(x, paste0(clean_data_dir, new_fname), row.names = FALSE)
# Read it in again so the numerics are read in now unlike previous time
qual_data <- read.csv(paste0(clean_data_dir, new_fname))
# Remove those that didn't finish and save again
qual_data <- qual_data[qual_data$Progress == 100,]
write.csv(qual_data, paste0(clean_data_dir, new_fname), row.names = FALSE)
# Recoding the randomization of the music
temp <- unlist(gregexpr(pattern ='\\|',as.character(qual_data$FL_8_DO)))
qual_data$M1_name <- substr(qual_data$FL_8_DO,1,temp-1)
qual_data$M2_name <- substr(qual_data$FL_8_DO,temp+1,nchar(as.character(qual_data$FL_8_DO)))
default_music_order <- paste0('M',1:4,'-',c('Stalker','Hutch','Trees','Piggy'))
M_order <- matrix(NA,length(qual_data$M1_name),2)
# Recoding the randomization of the videos
temp <- unlist(gregexpr(pattern ='\\|',as.character(qual_data$FL_13_DO)))
qual_data$V1_name <- substr(qual_data$FL_13_DO,1,temp-1)
qual_data$V2_name <- substr(qual_data$FL_13_DO,temp+1,nchar(as.character(qual_data$FL_13_DO)))
default_video_order <- paste0('V',1:3,'-',c('Face','Hear','Hills'))
V_order <- matrix(NA,length(qual_data$V1_name),2)
# Numeric form of the actual order
for (i in 1:nrow(V_order)){
V_order[i,1] <- which(default_video_order %in% qual_data$V1_name[i])
V_order[i,2] <- which(default_video_order %in% qual_data$V2_name[i])
M_order[i,1] <- which(default_music_order %in% qual_data$M1_name[i])
M_order[i,2] <- which(default_music_order %in% qual_data$M2_name[i])
}
# Using Numeric form to obtain emotion rating for Fear only and get compar vector with 1 and 0
M_order_data <- matrix(NA,length(qual_data$M1_name),2)
V_order_data <- matrix(NA,length(qual_data$M1_name),2)
M_compare_data <- matrix(NA,length(qual_data$M1_name),2)
V_compare_data <- matrix(NA,length(qual_data$M1_name),2)
for (i in 1:nrow(V_order)){
eval(parse(text=paste0('m<-c(qual_data$M',M_order[i,1],'.Emotions_3[',i,'],',
'qual_data$M',M_order[i,2],'.Emotions_3[',i,'])')))
M_order_data[i,] <- m
if (qual_data$M.Compare[i] == 'The First Option'){
M_compare_data[i,] <- c(1,0)
}else{
M_compare_data[i,] <- c(0,1)
}
eval(parse(text=paste0('v<-c(qual_data$V',V_order[i,1],'.Emotions_3[',i,'],',
'qual_data$V',V_order[i,2],'.Emotions_3[',i,'])')))
V_order_data[i,] <- v
if (qual_data$V.Compare[i] == 'The First Option'){
V_compare_data[i,] <- c(1,0)
}else{
V_compare_data[i,] <- c(0,1)
}
}
# Music
## Residuals
fit_1m <- lm(M_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2m <- lm(M_order_data[,2] ~ qual_data$Pre.Emotions_3)
M_residuals <- cbind(residuals(fit_1m),residuals(fit_1m))
# Change
M_change <- M_order_data - qual_data$Pre.Emotions_3
# Video
## Residuals
fit_1v <- lm(V_order_data[,1] ~ qual_data$Pre.Emotions_3)
fit_2v <- lm(V_order_data[,2] ~ qual_data$Pre.Emotions_3)
V_residuals <- cbind(residuals(fit_1v),residuals(fit_1v))
# Change
V_change <- V_order_data - qual_data$Pre.Emotions_3
long_format <- data.frame(ID=rep(1:50,4),
Rating=c(M_order_data,V_order_data),
R_change=c(M_change,V_change),
Votes=c(M_compare_data,V_compare_data),
Type=rep(c('Music','Video'),each=length(M_order)),
Type_Order=rep(c(rep(1,nrow(M_order)),rep(2,nrow(M_order))),2),
Overall_Order=rep(1:4,each=nrow(M_order)),
Name=c(substr(default_music_order[M_order],4,8),
substr(default_video_order[V_order],4,7))
)
music <- subset(long_format,long_format$Type=='Music'); music$Name <- factor(music$Name)
video <- subset(long_format,long_format$Type=='Video'); video$Name <- factor(video$Name)
m_descriptives <- describeBy(music$Rating,group = music$Name, mat = TRUE)
v_descriptives <- describeBy(video$Rating,group = video$Name, mat = TRUE)
kable(table(music$Name), col.names = c('Name', 'Frequency'), caption = 'Music Frequency Table')
kable(table(video$Name), col.names = c('Name', 'Frequency'), caption = 'Video Frequency Table')
limits <- aes(ymax = mean + (1.645*se), ymin=mean - (1.645*se)) # 90% Confidence intervals
dodge <- position_dodge(width=0.9)
j_dodge <- position_jitterdodge(dodge.width=.9, jitter.width = 1.5)
# Bar Graph
# Help from: http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/
p <- ggbarplot(music, x='Name', y='R_change', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = music, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Name), y = R_change, fill=Name, color=Name)) +
stat_compare_means(method = 'anova', label.y=105) +
ylab('Emotion Rating') +
xlab('Music') +
labs(fill = "Music") +
theme(legend.key = element_rect(colour = NA))
p
# Direct Comparison as opposed to the rating value
p <- ggbarplot(music, x='Name', y='Votes', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
# geom_jitter(data = music, position=j_dodge,show.legend=FALSE,
#        aes(x = as.numeric(Name), y = Votes, fill=Name, color=Name)) +
stat_compare_means(label.y=1.01) +
ylab('Votes') +
xlab('Music') +
labs(fill = "Music") +
theme(legend.key = element_rect(colour = NA))
p
## Videos
p <- ggbarplot(video, x='Name', y='Rating', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = video, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Name), y = Rating, fill=Name, color=Name)) +
stat_compare_means(method = 'anova', label.y=105) +
ylab('Emotion Rating') +
xlab('Video') +
labs(fill = "Video") +
theme(legend.key = element_rect(colour = NA))
p
# Help from: http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/
p <- ggbarplot(video, x='Name', y='Votes', fill='Name', palette='jco',add = c('mean_se'), alpha=.6) +
# geom_jitter(data = video, position=j_dodge,show.legend=FALSE,
#        aes(x = as.numeric(Name), y = Votes, fill=Name, color=Name)) +
stat_compare_means(label.y=1.01) +
ylab('Votes') +
xlab('Video') +
labs(fill = "Video") +
theme(legend.key = element_rect(colour = NA))
p
time_data <- data.frame(Rating=c(qual_data$Pre.Emotions_3,long_format$Rating),
Time=factor(c(rep(0,nrow(M_order)),long_format$Overall_Order),
labels = c('Pre','M1','M2','V1','V2')))
p <- ggbarplot(time_data, x='Time', y='Rating', fill='Time', palette='jco',add = c('mean_se'), alpha=.6) +
geom_jitter(data = time_data, position=j_dodge,show.legend=FALSE,
aes(x = as.numeric(Time), y = Rating, fill=Time, color=Time)) +
stat_compare_means(label.y=105, method = 'anova') +
stat_compare_means(label = "p.signif", method = "t.test", paired=TRUE,
ref.group = "Pre") +
ylab('Rating') +
xlab('Time') +
labs(fill = "Time") +
theme(legend.key = element_rect(colour = NA))
p
time_vote <- data.frame(Vote=c(M_compare_data,V_compare_data),
Time=rep(rep(c('First','Second'),each=nrow(M_order)),2))
p <- ggbarplot(time_vote, x='Time', y='Vote', fill='Time', palette='jco',add = c('mean_se'), alpha=.6) +
# stat_compare_means(label.y=1.05) +
# stat_compare_means(label = "p.signif", method = "t.test", paired=TRUE,
#              ref.group = ".all.") +
ylab('Rating') +
xlab('Time') +
labs(fill = "Time") +
theme(legend.key = element_rect(colour = NA))
t_stat <- describeBy(time_data$Rating, group = time_data$Time, mat=TRUE); row.names(t_stat) <- NULL
kable(t_stat[,c(2,4:6)], col.names = c('Time', 'N','Mean', 'SD'), caption = 'Music Frequency Table')
